package com.lsmo.android.carfans.view.car;

import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 * 车型view
 * @author SYX
 */
public class CarNavigationView extends LinearLayout{
	
	private ResolutionManager rm;
	private LinearLayout navLinearLayout, navContainer;
	private TextView titleText;
	private ImageButton  leftImgBtn,rightImgBtn;
	private int navContainerId = 00000001;
	private String navigationText;
	private int navLinearResId,leftNavigationResId,rightNavigationResId;

	private LayoutParams ff = new LayoutParams(new LayoutParams(
			LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
	private LayoutParams ww = new LayoutParams(new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
	
	public CarNavigationView(Context context) {
		super(context);
		rm = new ResolutionManager();
		init(context);
	}
	
	public void init(Context context) {
		this.setOrientation(VERTICAL);
		this.setLayoutParams(ff);
		
		navLinearLayout = new LinearLayout(context);
		navLinearLayout.setLayoutParams(rm.getNavigationView_layoutParams());
		navLinearLayout.setOrientation(HORIZONTAL);
		navLinearLayout.setGravity(Gravity.CENTER);
		navLinearLayout.setBackgroundResource(navLinearResId);
		navLinearLayout.setPadding(rm.getNavigationView_paddingLeft(),rm.getNavigationView_paddingTop(),
				rm.getNavigationView_paddingRight(),rm.getNavigationView_paddingButtom());
		
		//左侧图标
		leftImgBtn = new ImageButton(context);
		leftImgBtn.setLayoutParams(ww);
		leftImgBtn.setBackgroundResource(leftNavigationResId);
		navLinearLayout.addView(leftImgBtn);
		
		//标题
		titleText = new TextView(context);
		titleText.setLayoutParams(rm.getNavigationView_titleText_layoutLarams());
		titleText.setPadding(5, 0, 5, 0);
		titleText.setGravity(Gravity.CENTER_HORIZONTAL);
		titleText.setText(navigationText);
		titleText.setTextSize(rm.getNavigationView_titleTextSize());
		titleText.setTextColor(Color.WHITE);
		navLinearLayout.addView(titleText);
		
		//右侧按钮先隐藏
		rightImgBtn = new ImageButton(context);
		rightImgBtn.setLayoutParams(ww);
		rightImgBtn.setBackgroundResource(rightNavigationResId);
		navLinearLayout.addView(rightImgBtn);
		
		this.addView(navLinearLayout);
		
		navContainer = new LinearLayout(context);
		navContainer.setLayoutParams(ff);
		navContainer.setId(navContainerId);
		this.addView(navContainer);
	}
	
	
	public LinearLayout getNavContainer() {
		return navContainer;
	}

	public ImageButton getLeftImgBtn() {
		return leftImgBtn;
	}

	public void setLeftImgBtn(ImageButton leftImgBtn) {
		this.leftImgBtn = leftImgBtn;
	}

	public ImageButton getRightImgBtn() {
		return rightImgBtn;
	}

	public void setRightImgBtn(ImageButton rightImgBtn) {
		this.rightImgBtn = rightImgBtn;
	}

	public int getNavLinearResId() {
		return navLinearResId;
	}

	public void setNavLinearResId(int navLinearResId) {
		this.navLinearResId = navLinearResId;
		navLinearLayout.setBackgroundResource(navLinearResId);
	}

	public int getLeftNavigationResId() {
		return leftNavigationResId;
	}

	public void setLeftNavigationResId(int leftNavigationResId) {
		this.leftNavigationResId = leftNavigationResId;
		leftImgBtn.setBackgroundResource(leftNavigationResId);
	}

	public int getRightNavigationResId() {
		return rightNavigationResId;
	}

	public void setRightNavigationResId(int rightNavigationResId) {
		this.rightNavigationResId = rightNavigationResId;
		rightImgBtn.setBackgroundResource(rightNavigationResId);
	}
	
	
	public String getNavigationText() {
		return navigationText;
	}

	public void setNavigationText(String navigationText) {
		this.navigationText = navigationText;
		titleText.setText(navigationText);
	}
	

}
